package com.baidu.recognition.controller;

import com.alibaba.fastjson.JSONObject;
import com.baidu.recognition.config.baidu.BaiduApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author liuzhiqiang
 */
@RestController
@Slf4j
@CrossOrigin
@Api(tags = {"语音识别-短语音识别极速版"})
@RequestMapping("speed")
public class ShortSpeechSpeedController {

    @Autowired
    private BaiduApi baiduApi;

    @ApiOperation(value = "获取AccessToken")
    @GetMapping("getAccessToken")
    public JSONObject getAccessToken() {
        JSONObject jsonObject = baiduApi.getAccessToken();
        return jsonObject;
    }

    @ApiOperation(value = "语音识别极速版")
    @PostMapping("speechRecognition")
    public JSONObject speechRecognition(MultipartFile file, String token) {
        JSONObject jsonObject = baiduApi.speechRecognition(file, token);
        return jsonObject;
    }
}
